package com.quanxiaoha.weblog.web.controller;

import com.quanxiaoha.weblog.common.aspect.ApiOperationLog;
import com.quanxiaoha.weblog.common.utils.Response;
import com.quanxiaoha.weblog.web.model.vo.auth.RegisterReqVO;
import com.quanxiaoha.weblog.web.model.vo.auth.SendRegisterCodeReqVO;
import com.quanxiaoha.weblog.web.service.AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/register")
@Api(tags = "注册")
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/sendCode")
    @ApiOperation(value = "发送注册验证码")
    @ApiOperationLog(description = "发送注册验证码")
    public Response sendRegisterCode(@RequestBody SendRegisterCodeReqVO reqVO) {
        return authService.sendRegisterCode(reqVO.getMail());
    }

    @PostMapping
    @ApiOperation(value = "注册账号")
    @ApiOperationLog(description = "注册账号")
    public Response register(@RequestBody RegisterReqVO reqVO) {
        return authService.register(reqVO.getMail(), reqVO.getPassword(), reqVO.getCode());
    }
} 